package com.lxw.redis.study.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.GeoOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@Slf4j
public class RedisBatchOperationController {
    @Resource
    private RedisTemplate<String,String> redisTemplate;

    @GetMapping("/mget")
    public Object mget(){
        long start = System.currentTimeMillis();
        ValueOperations<String, String> operations = redisTemplate.opsForValue();
        List<String> keys = new ArrayList<>();
        List<String> values = operations.multiGet(keys);
        for (String value : values) {
            log.info("value:{}",value);
        }
        long end = System.currentTimeMillis();
        return (end-start);
    }
    public Object tmp(){
        GeoOperations<String, String> ops = redisTemplate.opsForGeo();
        return null;
    }
}
